package com.jingsong.studentapp.page;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import com.bigkoo.pickerview.builder.OptionsPickerBuilder;
import com.bigkoo.pickerview.listener.OnOptionsSelectListener;
import com.bigkoo.pickerview.view.OptionsPickerView;
import com.jingsong.studentapp.R;

import java.util.ArrayList;
import java.util.List;

/**
 * 校园信息
 */
public class ClassInfoActivity extends AppCompatActivity implements View.OnClickListener {

    private EditText etClassName;
    private EditText etStudentName;
    private TextView tvSchoolName;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_class_info);
        ImageView ivBack = findViewById(R.id.ivBack);
        ivBack.setOnClickListener(this);

        TextView tvTitle = findViewById(R.id.tvName);
        tvTitle.setText("班级信息");


        findViewById(R.id.rlName).setOnClickListener(this);
        findViewById(R.id.rlStudentName).setOnClickListener(this);
        findViewById(R.id.rlSeleteClass).setOnClickListener(this);
        findViewById(R.id.tvSure).setOnClickListener(this);


        etClassName = findViewById(R.id.etClassName);
        etStudentName = findViewById(R.id.etStudentName);
        tvSchoolName = findViewById(R.id.tvSchoolName);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.ivBack:
                finish();
                break;
            case R.id.tvSure:
                startActivity(new Intent(ClassInfoActivity.this, SuccessActivity.class));
                break;
            case R.id.rlSeleteClass:
                showPick();
                break;
        }
    }

    private void showPick() {
        List<String> items = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            items.add("英语班" + i);
        }
        OptionsPickerView pvOptions = new OptionsPickerBuilder(this, (options1, option2, options3, v) -> tvSchoolName.setText(items.get(options1))).setSubmitColor(getResources().getColor(R.color.black)).setCancelColor(getResources().getColor(R.color.item_text)).build();
        pvOptions.setPicker(items);
        pvOptions.show();
    }
}